import Vue from "vue";
import App from "./App.vue";
import router from "./router";

Vue.config.productionTip = false;

let instance = null;
function render(props) {
  instance = new Vue({
    router,
    render: (h) => h(App),
  }).$mount("#vueApp");
}

// 非独立运行
if (window.__POWERED_BY_QIANKUN__) {
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  // 直接渲染
  render();
}

export async function bootstrap() {
  console.log("vue app bootstraped");
}
export async function mount(props) {
  console.log("vue app mount", props);
  render(props);
}
export async function unmount() {
  console.log("vue app unmount");
  instance.$destroy();
  instance = null;
}
